/* summing.c -- 整数求和 */

#include <stdio.h>

int main(void)
{
  long num;
  long sum = 0L;
  int status;

  printf("Please enter an integet to be summed");
  printf("(enter 'q' to quit): ");
  status = scanf("%ld", &num);

  while (status == 1) // 当输入q时，scanf读取到的不是 "%ld"，此时scanf返回0
  {
    sum += num;
    printf("Please enter next integet: ");
    status = scanf("%ld", &num);
  }
  
  printf("The sum is %ld", sum);  

  return 0;
}